﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class IconModel extends BaseModel
{

    var $table  = 'icon';	
    var $_page_rows = 15;
	
    /* 插入数据 */
    function post($data)
    {    
	
		$time = time();     

		return $this->IU_Sql_Exe(array ('data' => array('iconname'=>"$data[iconname]",'iconcontent'=>"$data[iconcontent]",'description'=>"$data[description]",'viewtype'=>"$data[viewtype]",'config'=>"$data[config]",'time'=>"$time"), 'mode' => 'INSERT'));

    
    }

    function show()
    {   
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>" iconname!=''",'url' => 'admin/?app=icon&act=index'));		
		 $info['data'] = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>" iconname!='' ",'order' =>'time desc','limit' =>$info['page']['sql_limit']));
    
		 return $info;
        
    }

    function categoryshow($order='',$table_id=0,$catid='')
    {  
	     empty($order)?$order = ' add_time desc':'';
		 if(empty($catid))
		 {
   	    $conditions = " user_name !='0'  ";		 
		 }
		 else
		 {
   	    $conditions = " user_name !='0' and cat_id={$catid} ";		 
		 }

		  
	     $table = $this->_prefix.'content_'.$table_id.' ';
	  
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('table'=>"{$table}",'conditions' =>"{$conditions}",'url' => 'admin/?app='));		
		 
		 $info['data'] = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' * ','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
   
    }

    function iconshow($table='',$fields='',$conditions='', $order='',$limit='')
	{
			 
		 $info = $this->S_Sql_Exe(array('table'=>$table,'fields'=> $fields,'conditions' =>$conditions,'order' =>$order,'limit' =>$limit));
    
		 return $info;	
	}
 
 
    /* 删除数据 */
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editaction($id ='',$data = '')
    {    
		$time = time();  	      
		return $this->IU_Sql_Exe(array ('data' => array('iconname'=>"$data[iconname]",'iconcontent'=>"$data[iconcontent]",'description'=>"$data[description]",'viewtype'=>"$data[viewtype]",'config'=>"$data[config]",'time'=>"$time"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editiconcontent($id ='',$data = '')
    {   
     
		return $this->IU_Sql_Exe(array ('data' => array('iconcontent'=>"$data[iconcontent]"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }



    /* 通过id取出一条数据 */
    function oneshow($id ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));    
		 return $info;
        
    }


}




?>